﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SNAIL.Classes
{
    public class Thread
    {
        private List<MailMessage> _MessageObjects;

        public List<MailMessage> MessageObjects
        {
            get { return _MessageObjects; }
            set { _MessageObjects = value; }
        }

        private string _ThreadTopic;

        public string ThreadTopic
        {
            get { return _ThreadTopic; }
        }
        private DateTime _ThreadStartDateTime;

        public DateTime ThreadStartDateTime
        {
            get { return _ThreadStartDateTime; }
        }

        public override string ToString()
        {
            return _ThreadStartDateTime.ToString() + "-----TOPIC-----" + _ThreadTopic;
        }

        public Thread(List<MailMessage> MessageObjects)
        {
            this._MessageObjects = MessageObjects;
            this._MessageObjects.Sort(delegate(MailMessage m1, MailMessage m2)
            {
                return m1.MessageObject.ConversationIndex.CompareTo(m2.MessageObject.ConversationIndex);
            });
            this._ThreadStartDateTime = this._MessageObjects[0].MessageObject.ReceivedTime;
            this._ThreadTopic = this._MessageObjects[0].MessageObject.ConversationTopic;
        }
    }
}
